package com.ibeetl.cms.service;


import com.ibeetl.admin.core.service.CoreBaseService;
import com.ibeetl.admin.core.util.PlatformException;
import com.ibeetl.cms.dao.CmsCatalogDictDao;
import com.ibeetl.cms.entity.CmsCatalog;
import com.ibeetl.cms.entity.CmsCatalogDict;
import org.beetl.sql.core.engine.PageQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;






/**
 * CoreCatalogDict Service
 */

@Service
@Transactional
public class CmsCatalogDictService extends CoreBaseService<CmsCatalogDict> {

    @Autowired private CmsCatalogDictDao cmsCatalogDictDao;

    public PageQuery<CmsCatalogDict>queryByCondition(PageQuery query){
        PageQuery ret =  cmsCatalogDictDao.queryByCondition(query);
        queryListAfter(ret.getList());
        return ret;
    }

    public void batchDelCoreCatalogDict(List<Long> ids){
        try {
            cmsCatalogDictDao.batchDelCoreCatalogDictByIds(ids);
        } catch (Exception e) {
            throw new PlatformException("批量删除CoreCatalogDict失败", e);
        }
    }

    public List<Long> getDictIdByCatalog(Long catalogId) {
        List<Long> l = this.cmsCatalogDictDao.getDictIdByCatalog(catalogId);
        return l;
    }

    public List<CmsCatalog> getCatalogByDictTypeAndValue(String type, String value) {
        List<CmsCatalog> l = this.cmsCatalogDictDao.getCatalogByDictTypeAndValue(type, value, null);
        return l;
    }
    public List<CmsCatalog> getCatalogByDictTypeAndValue(String type, String value, Long parentCatalogId) {
        List<CmsCatalog> l = this.cmsCatalogDictDao.getCatalogByDictTypeAndValue(type, value, parentCatalogId);
        return l;
    }
}